{extend name="layout:base" /}
{block name="page_content"}
  <?php if($auth->check('create')): ?>
    <div class="row maintop">
      <div class="col-xs-4 col-sm-2">
        <a href="{:url('create')}" class="btn btn-sm btn-primary mr-10">
          <i class="ace-icon fa fa-plus bigger-110"></i>
          添加
        </a>
      </div>
    </div>
  <?php endif; ?>

  <div class="row">
    <div class="col-xs-12">
      <div>
        <div class="text-danger">添加或修改后菜单后，管理员用户需要重新登录才能看到权限和左侧菜单变化。</div>
        <form method="post" action="{:url('resort')}" >
          <table class="table table-striped table-bordered table-hover" id="dynamic-table">
            <thead>
              <tr>
                <th>菜单名称</th>
                <th>页面控制器名</th>
                <th>页面方法名</th>
                <th class="field-icon center">ICON图标</th>
                <th class="center">状态</th>
                <th class="field-sort center">排序</th>
                <th class="center">操作</th>
              </tr>
            </thead>
            <tbody>
              {volist name="list" id="vo"}
                <tr>
                  <td>
                    {$vo.shown_title|raw}
                  </td>
                  <td>{$vo.controller}</td>
                  <td>{$vo.action}</td>
                  <td class="field-icon center">
                    <i class="{$vo.icon}"></i>
                  </td>
                  <td class="center">
                    {$vo.status|get_field_text='menu_status',###}
                  </td>
                  <td class="field-sort center">
                    <input type="text" maxlength="4" name="items[{$vo.id}]" value="{$vo.sort}" class="field-style">
                  </td>
                  <td class="center">
                    <?php if($auth->check('update')): ?>
                      <a class="green" href="{:url('update', ['id' => $vo['id']])}">
                        <i class="ace-icon fa fa-pencil bigger-130"></i>编辑
                      </a>
                    <?php endif; ?>
                    <?php if($auth->check('delete')): ?>
                      <a class="red" href='javascript:void(0)' onclick="alert_del('{:url("delete", ['id' => $vo['id']])}', '确认要删除吗？');" class="tooltip-error" data-rel="tooltip" title="删除">
                        <i class="ace-icon fa fa-trash-o bigger-130"></i>删除
                      </a>
                    <?php endif; ?>
                  </td>
                </tr>
              {/volist}
            </tbody>
          </table>
          <?php if($auth->check('resort')): ?>
            <button class="btn btn-info" type="submit">
              更新排序
            </button>
          <?php endif; ?>
        </form>
      </div>
    </div>
  </div>
{/block}